<template>
  <div>
      <div class="log-wrapper" v-if="listData.length > 0">
          <div class="log-item" v-for="(item, index) in listData" :key="index">
              <div>
                  {{index+1}}.日期: {{item.date}}
                  <br />
                  &nbsp;&nbsp;&nbsp;时间: {{item.time}}
                  <br />
                  &nbsp;&nbsp;&nbsp;血糖: {{item.sugar}}
                  <br />
                  &nbsp;&nbsp;&nbsp;<span>备注: {{item.desc}}</span>
              </div>
          </div>
      </div>
      <van-empty v-else description="暂无数据" />
  </div>
</template>

<script>
export default {
    data() {
        return {
            listData: []
        }
    },
    mounted() {
        if (localStorage.getItem('bloodlog')) {
            let listData = localStorage.getItem('bloodlog')
            this.listData = JSON.parse(listData)
        }
    }
}
</script>

<style lang="less">
body {
  background: white;
}
.log-wrapper {
    width: 100%;
    font-size: 16px;
    padding: 10px;
    box-sizing: border-box;
}
.log-item {
    width: 100%;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    padding: 10px 5px;
    box-sizing: border-box;
    border-radius: 3px;
    margin-top: 5px;
    span {
        display: inline-block;
        width: calc(100% - 20px);
        word-wrap: break-word;
        word-break: normal; 
    }
}
</style>